package cn.wolfcode.trip.app.controller;

import cn.wolfcode.trip.base.query.ClickQueryObject;
import cn.wolfcode.trip.base.query.CollectionceQueryObject;
import cn.wolfcode.trip.base.service.IClickService;
import cn.wolfcode.trip.base.util.JsonResult;
import jdk.nashorn.internal.objects.annotations.Getter;
import com.github.pagehelper.PageInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("clicks")
public class ClickController {
    @Autowired
    private IClickService clickService;


    /**
     * 查询判断是否有对应的参数信息
     * @param qo
     * @return
     */
    @GetMapping("/statusId")
    public boolean select(CollectionceQueryObject qo){
        return clickService.selectId(qo);
    }
    @PostMapping
    public JsonResult save(CollectionceQueryObject qo){
        clickService.save(qo);
        return new JsonResult();
    }
    @PutMapping
    public JsonResult delete(CollectionceQueryObject qo){
        clickService.delete(qo);
        return new JsonResult();
    }
    /**
     * 获取点赞消息列表
     * @param qo
     * @return
     */
    @GetMapping("/{userId}")
    public PageInfo list(ClickQueryObject qo){
        qo.setOrderBy("c.id desc");
        return clickService.query(qo);
    }

    /**
     * 查找未查看的系统消息
     * @param userId
     * @return
     */
    @GetMapping("/nums")
    public Integer getNoReadCount(Long userId){
        return clickService.getNoReadCount(userId);
    }

    /**
     * 设置系统消息已读
     * @param userId
     * @return
     */
    @PutMapping("/{userId}")
    public Object setRead(@PathVariable Long userId){
        clickService.setRead(userId);
        return new JsonResult();
    }

    @GetMapping
    public Integer selsectId(Long strategyId){
        return clickService.selsectId(strategyId);
    }


}
